<template>
    <div class="tods">
      <h1 class="tod">todos</h1>
      <input
        type="text"
        style="background: white"
        v-model="puts"
        placeholder="What needs to be done?"
        class="input"
        @keyup.enter="dian"
      />
      <div class="llo">
        <ol>
          <li v-for="(item, index) in lista" :key="index">
              <input type="checkbox" v-model="item.checked">
              {{ item.name }}
          </li>
        </ol>
      </div>
      <div class="tos">
        <span>数量</span>
        <span class="span">
          <button @click="All">All</button>
          <button @click="Active">Active</button>
          <button @click="Component">Component</button>
        </span>
        <span></span>
      </div>
    </div>
  </template>
  
  <script setup>
  import { ref } from "vue";
  import { useRouter } from "vue-router";
  const router = useRouter();
  const puts = ref();
  const list = ref([]);
  const lists = ref(JSON.parse(localStorage.getItem("list")) || []);
  const lista=ref(lists.value.filter((item)=>item.checked==true));



  const dian = () => {
    list.value.push({name:puts.value,checked:true});
    console.log(puts.value);
    localStorage.setItem("list", JSON.stringify(list.value));
  };
  
  const All = () => {
    router.push("/all");
  };
  const Active = () => {
    router.push("/active");
  };
  const Component = () => {
    router.push("/component");
  };
  </script>
  
  <style lang="scss" scoped>
  .tods {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #f5f5f5;
    .tod {
      color: rgba(175, 47, 47, 0.15);
      // font-weight: 100;
      font-size: 100px;
    }
    .input {
      width: 80%;
      padding: 16px 16px 16px 60px;
      border: none;
      box-shadow: 0px 7px 10px 1px;
      font-size: 24px;
      outline: none;
    }
    .tos {
      width: 80%;
      background-color: white;
      height: 50px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .span {
        width: 30%;
        display: flex;
        align-items: center;
        justify-content: space-around;
        font-size: 10px;
        button {
          border: none;
          background: white;
        }
      }
    }
    .llo {
      width: 80%;
      background-color: white;
      ol{
          list-style: none;
      }
    }
  }
  </style>